<?php
if (!empty($csv))
{
?>
    <h2 class="h2-title">Import Product !!!</h2>
    <form action="<?=base_url()?>backend/product/import_from_csv" method="POST">
	<table style="width: 100%;">

	<tr>
	<?php
		$headers = array_keys($csv[0]);

		foreach ($headers as $th_tag)
        {
			$hdr = trim(str_replace('"','',$th_tag));
			echo "<th>".$hdr."</th>\n";
		}
	?>
	</tr>

	<?php

		foreach ($csv as $key => $line)
        {
			echo "<tr>\n";
			foreach ($line as $f => $d)
            {
				$FIELD = trim(str_replace('"','',$f));
				$FDATA = trim(str_replace('"','',$d));
				if ($FIELD != '')
                {
					echo "<td style='text-align: center'>";
					echo utf8_decode($FDATA) . "\n";
					echo form_hidden("line_$key"."[".$FIELD."]",$FDATA);
					echo "</td>\n";
				}

			}
			echo "</tr>\n";
		}
	?>
	</table>
	<input type="hidden" name="csvgo" value="1"/>
    <input type="submit" class="sub" value="Import" name="sub"/>
    <a href='<?=base_url()?>backend/product' class='bnt'>Quay lại</a>
	</form>
<?php
}
else
{
	echo "<h1>File Import trống</h1>";
	echo "<a href='<?=base_url()?>backend/product' class='bnt'>Quay lại</a>";
}
?>